'''
@project:pythonProjectT174
@auther:zhongyingjie
@file:qddenglu.py
@date:2022/11/5 16:37
@desc:
'''
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
import unittest
from common.broswersetting import broswersetting
name='客户A'
class qddenglu(broswersetting):
    # def setUp(self) -> None:
    #     self.driver = webdriver.Chrome()  # 创建一个浏览器对象
    #     self.driver.get('http://192.168.186.111/tinyshop/')
    #     self.driver.maximize_window()
    #     self.driver.find_element(By.XPATH, '//a[text()="登录"]').click()
    # def tearDown(self) -> None:
    #     self.driver.quit()
    # @unittest.skip('无理由跳过')
    def test_dlzc(self):
        self.zzdl('502822488@qq.com','cn19961011')
        # self.driver.find_element(By.ID, 'account').send_keys('502822488@qq.com')
        # self.driver.find_element(By.NAME, 'password').send_keys('cn19961011')
        # self.driver.find_element(By.XPATH, '//button[text()="登录"]').click()
        yh = self.driver.find_element(By.XPATH, '//*[@id="header"]/div[1]/div/div[1]').text
        try:
            self.assertIn('你好:502822488@qq.com',yh)
        except Exception as e:
            self.driver.get_screenshot_as_file('F:\\csxm\\tinyshop_t174\\images\\dl.png')
            raise

    # @unittest.skipIf(name=='客户A','客户A不需要这个功能')
    def test_mimacu(self):
        # self.driver.find_element(By.XPATH, '//a[text()="登录"]').click()
        # self.driver.find_element(By.ID, 'account').send_keys('502822488@qq.com')
        # self.driver.find_element(By.NAME, 'password').send_keys('cn123456')
        # self.driver.find_element(By.XPATH, '//button[text()="登录"]').click()
        self.zzdl('502822488@qq.com','cn123456')
        cw=self.driver.find_element(By.CLASS_NAME,'invalid-msg').text
        try:
            self.assertIn('密码错误！',cw)
        except Exception as e:
            self.driver.get_screenshot_as_file('F:\\csxm\\tinyshop_t174\\images\\dl.png')
            raise
    # @unittest.expectedFailure
    def test_mmbnwk(self):
        # self.driver.find_element(By.XPATH, '//a[text()="登录"]').click()
        # self.driver.find_element(By.ID, 'account').send_keys('502822488@qq.com')
        # self.driver.find_element(By.NAME, 'password').send_keys('')
        # self.driver.find_element(By.XPATH, '//button[text()="登录"]').click()
        self.zzdl('502822488@qq.com','')
        bwk=self.driver.find_element(By.CLASS_NAME,'invalid-msg').text
        try:
            self.assertIn('密码不能为空',bwk)
        except Exception as e:
            self.driver.get_screenshot_as_file('F:\\csxm\\tinyshop_t174\\images\\dl.png')
            raise



if __name__=='__main__':
    unittest.main()